package com.ktjiaoyu.t351.service.user;

import com.ktjiaoyu.t351.dao.user.SysUserDao;
import com.ktjiaoyu.t351.entity.SysUser;
import com.ktjiaoyu.t351.exception.LoginException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ClassName : SysUserServiceImpl
 * @Description :
 * @Author : Lzz
 * @Date: 2023/10/16 09:52:59
 */
@Service("userService")
public class SysUserServiceImpl implements SysUserService{

    @Autowired
    private SysUserDao sysUserDao;

    @Override
    public SysUser login(SysUser sysUser) throws LoginException {
        SysUser user = sysUserDao.findUser(sysUser);
        if(user == null){
            throw new LoginException("用户信息不存在，请重试！");
        }else if(!sysUser.getPassword().equals(user.getPassword())){
            throw new LoginException("用户账号或密码错误，请重试！");
        }
        return user;
    }
}
